// https://leetcode.cn/problems/minimum-size-subarray-sum/description/


class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int n = nums.size();
        int sum = 0;
        int len = 0x3f3f3f;
        for(int i = 0, j = 0; j < n; ) {
            sum += nums[j];
            if(sum < target) {
                j++;
            }else {
                if(j - i + 1 < len) {
                    len = j - i + 1;
                }
                sum -= nums[i];
                sum -= nums[j];
                i++;
            }
        }
        return len == 0x3f3f3f ? 0 : len;
    }
};